import React from 'react';
import Form from 'taro-vform';
import { RadioGroup, CheckboxGroup, Radio, Checkbox, View } from '@tarojs/components';
import { Space } from '@/components/UiComponents'
export default (props) => {
  const { require, label, onlyKey, placeholder, option, type, setting } = props;
  return (
    <Form.Item
      name={onlyKey ? onlyKey : label}
      label={label}
      rules={[{ required: require, message: `${label}不能为空` }]}
    >
      {setting === 'radius' ? (
        <RadioGroup>
          <View className='form_CheckedBox_box'>
            <Space direction="vertical">
              {option.map((item, index) => {
                return (
                  <Radio style={{ width: '100%' }} key={index} value={item}>
                    {item}
                  </Radio>
                );
              })}
            </Space>
          </View>

        </RadioGroup>

      )
        : (
          <CheckboxGroup>
            <View className='form_CheckedBox_box'>
              <Space direction="vertical">
                <Checkbox style={{ width: '100%' }} key={index} value={item}>
                  {item}
                </Checkbox>
              </Space>
            </View>

          </CheckboxGroup>
        )}
    </Form.Item>


  );
};
